//
//  NewsViewController.m
//  News_lzz
//
//  Created by qianfeng01 on 15-6-14.
//  Copyright (c) 2015年 李忠. All rights reserved.
//

#import "NewsViewController.h"
#import "Model.h"

@interface NewsViewController () 
@end

@implementation NewsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self firstDo];
    [self requestNetAndDownloadDataWithUrlType:self.typeArr[0]];
}

- (void)firstDo {
    self.adView = [[ADView alloc] initWithFrame:CGRectMake(0, 0, kScreenSize.width,160)];
    self.tableView.tableHeaderView = self.adView;
    [self.tableView registerNib:[UINib nibWithNibName:@"NewsCell" bundle:nil] forCellReuseIdentifier:@"NewsCellOne"];
    [self.tableView registerNib:[UINib nibWithNibName:@"NewsCellTwo" bundle:nil] forCellReuseIdentifier:@"NewsCellTwo"];
}

/*
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [self.dataArr[indexPath.row] pics] ? 169: 100;
}
*/

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    Model *model = self.dataArr[indexPath.row];
    if (model.pics) {
        NewsCell *newsCellTwo = [tableView dequeueReusableCellWithIdentifier:@"NewsCellTwo" forIndexPath:indexPath];
        
        return [newsCellTwo setPicsWithModel:model];
    } else {
        NewsCell *newsCell = [tableView dequeueReusableCellWithIdentifier:@"NewsCellTwo" forIndexPath:indexPath];
        return [newsCell setCellWithModel:model];
    }
}

- (void)itemClick:(UIBarButtonItem *)item {
    switch (item.tag) {
        case 101:
        {//头条
            [self requestNetAndDownloadDataWithUrlType:self.typeArr[0]];
        }
            break;
        case 102:
        {
            
        }
            break;
        case 103:
        {//体育
            [self requestNetAndDownloadDataWithUrlType:self.typeArr[1]];
        }
            break;
        case 104:
        {
            
        }
            break;
        case 105:
        {
            
        }
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
